package com.smartwebx.ha.web.admin.module.screen.user;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Param;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.smartwebx.ha.biz.assign.HaUserManager;
import com.smartwebx.ha.dal.assign.bean.HaUser;
import com.smartwebx.ha.usebean.json.HaUserJson;
import com.smartwebx.ha.util.JsonHelper;

public class AjaxGetUser {
	@Autowired
	private HttpServletResponse response;
	@Autowired
	private HaUserManager haUserManager;

	public void execute(@Param("userid") Integer userid) throws Exception{
		response.setContentType("application/json");
		PrintWriter out = response.getWriter();
		ObjectMapper mapper=JsonHelper.objectMapperMixinOption(HaUser.class, HaUserJson.class);
		HaUser user = haUserManager.findById(userid);
		mapper.writeValue(out, user);
	}
}